import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:klfz_flutter/book/widgets/reader_page_agent.dart';
import 'package:klfz_flutter/http/http_utils.dart';
import 'package:klfz_flutter/model/chapter_result.dart';

class ReaderConfig {

  //阅读区域高度
  static double getReaderSceneHeight() {
    return ScreenUtil().screenHeight - 90 - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight;
  }
  //阅读区域宽度
  static double getReaderSceneWidth() {
    return ScreenUtil().screenWidth - 30;
  }

  //根据id获取章节数据
  static Future<Chapter> getChapterbyId(int id) async => HttpUtils.get("/novel/novelChapter/queryById?id=${id}").then((value) {
    Chapter result = Chapter.fromJson(value["result"]);
    var pageOffsets = ReaderPageAgent.getPageOffsets(result.content ?? "", ReaderConfig.getReaderSceneHeight(), ReaderConfig.getReaderSceneWidth(), 14);
    result.pageOffsets = pageOffsets;
    return result;
  });

}